package com.kf.comkfjiedu;

import com.kf.common.utils.StringUtils;
import com.mysql.cj.jdbc.Driver;
import org.junit.Test;
import sun.misc.Unsafe;

import javax.validation.constraints.Max;
import java.io.*;
import java.lang.reflect.Array;
import java.net.Socket;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.*;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.*;

public class juc {
    public volatile AtomicInteger  inc = new AtomicInteger(1);;
    public void increase() {
        inc.getAndIncrement();
    }

    public static void main(String[] args) throws InterruptedException, ClassNotFoundException, SQLException, IllegalAccessException, InstantiationException, FileNotFoundException {

      /*
        ConcurrentHashMap concurrentHashMap=new ConcurrentHashMap<>();
        for (int i = 0; i < 1000; i++) {
            int finalI = i;
            new Thread(()-> concurrentHashMap.put(finalI,1),String.valueOf(i)).start();
        }*/
        Map hashmap=new HashMap();
        ConcurrentHashMap cmap = new ConcurrentHashMap<>();
        cmap.put(1,1);
        ReentrantLock lock=new ReentrantLock();
      lock.lock();
      lock.unlock();
      TreeSet treeSet=new TreeSet<>();
        TreeMap treeMap=new TreeMap<>();
        treeMap.put(1,1);
        System.getProperties().forEach((k,v)-> System.out.println(k+" "+v));

        // 1.加载数据访问驱动
        Class.forName("com.mysql.jdbc.Driver");
        new Driver();
        //2.连接到数据"库"上去
        Connection conn= DriverManager.getConnection("jdbc:mysql://localhost:3306/mydb?characterEncoding=GBK", "root", "");
        //3.构建SQL命令
        Statement state=conn.createStatement();
        String s="insert into xs values('008','李丽','四中')";
        state.executeUpdate(s);
        Class.forName("com.kf.comkfjiedu.a1").newInstance();
        FileInputStream fileInputStream = new FileInputStream("");
        BufferedInputStream bufferedInputStream = new BufferedInputStream(fileInputStream);
        BufferedOutputStream bufferedOutpuStream1 = new BufferedOutputStream(new FileOutputStream(""));
        ThreadPoolExecutor threadPoolExecutor = (ThreadPoolExecutor) Executors.newCachedThreadPool();
        threadPoolExecutor.execute(()-> System.out.println("s"));
        new Thread().start();
    }

    static class a2{
        a2() {

        }
       public void dod(){

            String a = null; String b = null;
            if (StringUtils.isEmpty(a)){
                a="1";
            }else if (StringUtils.isEmpty(b)){
                b="2";
            }else {
                synchronized (a){
                    System.out.println(a+"11111111");
                }
                synchronized (b){
                    System.out.println(b);
                }
            }
        }
    }
}

